Configuring reconfigurable intelligent surfaces using a practical codebook approach

It is proven that the scattering, reflection, and refraction properties of electromagnetic signals can be adapted and managed by using reconfigurable intelligent surfaces (RISs). In this paper, we have investigated the performance of a single-input-single-output (SISO) wideband system in terms of achievable data rate by optimizing the phases of RIS elements and performing a fair power allocation for each subcarrier over the entire bandwidth. A new beamforming codebook is developed from which the maximizing signal-to-noise (SNR) configuration is selected. The channel state information (CSI) along with the selected maximizing SNR configuration is then used by the proposed power algorithm to obtain the optimal configuration of the RIS. To validate our proposed method, it is compared with state-of-the-art semidefinite relaxation (SDR) scheme in terms of performance, complexity and run-time consumption. Our method shows dramatically lower computational complexity than the SDR method and achieves an order of 2.5 increase in the achievable data rate with an optimized RIS compared with an un-configured surface.

www.nature.com/scientificreports/ • Computational complexity and run-time analysis of the proposed power method are compared against the SDR method. Simulation results show that the proposed power method achieves a very close achievable rate in comparison to the benchmark scheme, but with significantly lower computational complexity.
The rest of the paper is organized as follows. Section "System model" presents the system model. In "RIS configuration for data rate maximization" Section the RIS configuration for data rate maximization is studied. The simulation results are discussed in "Simulation results" Section while the conclusion is given in "Conclusion" Section.

System model
A single-input-single-output (SISO) wideband model where a single antenna (transmitter) communicates with a single user (receiver) is considered. A RIS with N reconfigurable elements is considered within the coverage region of the transmitter and the receiver as shown in Fig. 1. The transmission is carried out using OFDM. Let s(k) refer to the transmitted discrete-time signal in the complex baseband domain so, the discrete-time signal received at the receiver can be represented as 2 : where {h θ [l] : l = 0, . . . , M − 1} is the wideband channel in the time domain with the RIS configuration θ and e[k] ∼ N C 0, σ 2 is the receiver noise. h d [l] is given by: where h d [l] is the access point (AP)-User uncontrollable direct channel, u l ∈ C N is the AP-RIS-User controllable indirect channels via all RIS N elements and the reflection coefficients of all elements is denoted by w θ ∈ C N . OFDM transmission with K > M subcarriers and cyclic prefix length M − 1 is considered. Consequently, time domain signals with a block of K + M − 1 are sent to generate a block of OFDM signal that contains K of parallel subcarriers by applying the DFT: The system model in (3) can be illustrated in vector form as follows: where ⊙ describes the Hadamard product. The channel vector h θ can be realized a function of w θ as per following: (1) . . .
. . .  contains all the components of the AP-RIS-User controllable indirect propagation channels. The perfect channel model is assumed to be available in the system. F is a K × M DFT matrix with the (v, k)th element being e − 2πkv K and w θ = w θ 1 , . . . , w θ N T ∈ C N×1 contains the reflection coefficients of the RIS that accounts for the effective phase shifts (θ 1 , θ 2 , . . . , θ N ) ∈ [−π, π) and amplitude coefficients (γ 1 , γ 2 , . . . , γ N ) ∈ [0, 1] . Each RIS element in a one-bit RIS design can switch between two states of phase shifts, π/2 or −π/2 . We inspired the generation of such phase matrices from the beamforming codebook of the RIS presented in 9 . Consequently, we adopted a practical discrete phase model for all RIS elements rather than continuously adjusted phase shifts. The sum rate over the K subcarriers, for a given RIS configuration, assuming equal power allocation and under perfect channel at the receiver is given as: where B is the channel bandwidth, P v is the transmit power assigned for subcarrier v, M is the number of channel taps, f H v is the v th row of the DFT matrix F. The upper bound for (6) is given by 2 : where � · � 1 is the L 1 norm.
Wideband channel model. The following wideband channel is considered 10 : where, L d is the number of propagation paths, B d,ℓ ≥ 0 is the pathloss of the ℓ th path from the AP to the user as per Fig. 1, τ d,ℓ is the propagation delay and α is the sampling delay over the shortest path. Similarly, the controllable path is given by: The propagation paths L a and L b are from the AP to the RIS and from the RIS to the users, respectively. B H,ℓ ≥ 0 , and B G,ℓ b ≥ 0 , are the pathlosses from the AP to the RIS and from the RIS to the user, as per Fig. 1. τ H,ℓ and τ G,ℓ b are the propagation delays to and from the RIS and a(ϕ, θ) = √ G(ϕ, θ) e jK(ϕ,θ) T U 1 , . . . , e jK(ϕ,θ) T U N T is the array response vector. Where G(ϕ, θ) is the directivity pattern for each element, θ and ϕ are the elevation and a z i m u t h a n g l e s , K(ϕ, θ) = 2π [cos(θ) cos(ϕ), cos(θ) sin(ϕ), sin

RIS configuration for data rate maximization
The wideband case with K orthogonal subcarriers presents a more difficult RIS optimization problem than narrowband (containing a single subcarrier). The maximization of (6) requires estimating the optimal vector w θ and fairly allocating power for each subcarrier.
Beamforming codebook. For large value of N, there are 2 N possible RIS configurations and requires extensive analysis to find the optimal configuration, which is practically unattainable. Existing research relies on accurate configurations, in which a RIS with N reflecting elements may swap between N orthogonal configurations. For a particular incident and desirable reflected angles, the structure of the optimal RIS phase shifts remains consistent with the 2D-DFT codebook 9 . Consequently, each column of the codebook beamformer W θ = F(N v ) ⊗ F(N h ) ∈ C N×N , ⊗ refer to the kronecker product, can be a possible reflection configuration for an incident signal in a certain beam direction. We have extended W θ to W θ 4N where W θ 4N = W θ , −W θ , W (θ ,flip) , −W (θ ,flip) ∈ C N×4N , to invert the phases of columns and rows in a way to increase the varieties of the codebook phase configurations. W (θ ,flip) denotes the output matrix when every column is flipped upside-down. For such a codebook setting, the probability of getting a strong SNR configuration is very high. The DFT matrices for the columns F(N v ) and F(N h ) can be denoted as: ). N v and N h are the vertical and horizontal elements of RIS, as illustrated in Fig. 1. The phase shifts generated by the codebook must be quantized to meet the design requirements of the RIS. As a result, the reflection coefficient w θ for element i can be either 9 . Let us denote the best phase configuration w θ CodeBook ∈ W θ 4N that can be generated from the codebook. It is considered as the benchmark for obtaining the maximum SNR.
where, P is the power for all subcarriers. We search in the codebook W θ 4N for the best configuration that maximize the SNR in (11). Figure 2 depicts the related strongest and weakest SNR with a difference of around 20 dB. The strongest SNR configuration is further utilized in Algorithm 1. Weakest SNR Figure 2. The best configuration in the codebook that gives the maximum SNR and the worst configuration that gives the minimum SNR. www.nature.com/scientificreports/ Problem formulation. In this paper, we optimize the transmit power P and the reflection coefficients vector w θ for all RIS elements to maximize the sum rate at the receiver. The sum rate maximization problem can be mathematically represented in terms of optimization problem (OP) as follows: Constraint (C1) ensures that each RIS element's reflection has no pathloss. Unlike relays, RIS elements do not amplify or decode, necessitating the use of unit magnitude elements. Constraint (C2) confirms that the power allocated for all subcarriers should not exceed the base station power budget and must be ≥ 0, as per Constraint (C3). It is noted that the (OP1) is non-convex over the unit modular (C1) on all RIS elements 8 . We overcome the non-convexity by iteratively applying the power method until it converges to the most preferred w θ that will affect all number of subcarriers. Moreover, the power is allocated to each subcarrier in (C2) by using the wellknown water-filling algorithm.
Proposed solution. Power method. We use the power method to find a low-complex solution to optimize the RIS phase shifts. It calculates the dominant eigen vector of the channel power. The (OP1) problem in (12) can be simplified to be equivalent to the following channel gain: Thus the summation of the objective function of (13) for the entire number of subcarriers (v = 0, 1, . . . , K − 1) is denoted by the channel gain h θ 2 : We select the w θ CodeBook from the codebook W θ 4N ∈ C N×4N to initialize the power method to maximize the quadratic form of the channel h θ 2 as shown in Algorithm 1. The power method finds the dominant eigenvalue by www.nature.com/scientificreports/ w θ = w θ CodeBook until convergence. In each step we find a vector of w θ solution and then, we project it to the closest one-bit RIS phases by quantizing the vector entries of phases to be either π/2 or −π/2.
Semidefinite relaxation method. The SDR is a widely used technique for dealing with the non-convex unitmodulus constraint by converting the passive beamforming vector w θ into a rank-one and positive semi-definite matrix. The initial non-convex problem is converted into a convex Semidefinite Program (SDP) problem using the SDR method, which may then be addressed by a variety of effective convex optimization tools. The (OP2) objective function of (13) is described as: so, (OP2) is equivalent to: It is simple to identify problem (OP3) as a quadratically constrained quadratic program (QCQP) problem that can be expressed as a homogeneous QCQP problem, particularly, by denoting: where, t is an auxiliary variable and φ = w θ w T θ . Optimization Problem (OP3) is transformed into the following problem: It should be noticed that (OP4) is still non-convex because of the rank-one constraint. The rank-one constraint is thus bypassed by using the SDR approach, which converts (OP4) into a convex SDP that can be successfully solved using modern convex optimization solvers like CVX 11 . It is essential to keep in mind that the optimum objective value of (OP4) serves as an upper bound on that of (OP2). However, the best solution φ * to (OP4) might not be a rank-one answer. As a result, we arrive at the following rank-one solution using the Gaussian randomization method φ * = ��� H . Where, � = [ρ 1 , · · · , ρ N+1 ] and � = diag(σ 1 , · · · , σ N+1 ) are unitary and diagonal matrices, respectively, both with the size of (N + 1) × (N + 1) . We get sub-optimal solution to (OP4) , w * θ = ��r , where r ∈ C (N+1)×1 is a random vector which is generated based on r ∈ N C (0, I N+1 ) with zero mean circularly symmetric complex Gaussian (CSCG) distribution and covariance matrix I N+1 . We eventually arrive at suboptimal solution to (OP2) as w * θ = e j∠([w * θ ] 1:N /[w θ ] N+1) .
Water-filling algorithm. The power distribution for all subcarriers P 0 , . . . , P K−1 are satisfying P = 1 K K−1 v=0 P v where, P v = E |s[v]| 2 is the power provided to subcarrier v. The notation E{.} is the expectation operator. The power allocation for the subcarriers can be optimized by the water-filling algorithm 8 .
where, the parameter η ≥ 0 is chosen to satisfy 1 K K−1 v=0 P v = P . The water-filling algorithm is used to allocate the transmitted power fairly to all subcarriers. In Fig. 3, we show the comparison of the power allocation between the power method and the RIS surface when it is un-configured (replaced by a metallic sheet) to demonstrate www.nature.com/scientificreports/ how the algorithm allocates the power to each subcarrier taking into consideration the channel status. The noise level is very low in case of the power method (in terms of 10 −5 ) while it is high in the un-configured surface case, consequently, the water-filling algorithm will assign the power to each subcarrier taking into consideration the noise level e.g., refering to the arrows in Fig. 3, the water-filling algorithm assign less power to the subcarriers with bad channel status and vice versa.

Computational complexity. This section addresses the level of computational complexity involved in
the proposed optimization method of the RIS phases and subcarriers power allocation. We approximated the O complexity of the suggested algorithms by using the same method in 12 . In the power method, the term h equivalent needs (N + 1) 2 complex multiplications, whereas, the term h equivalent i needs (N + 1) complex multiplications and phases quantization need N complex computations. Moreover, assigning power to all subcarriers requires 2(K × M) complex multiplications. Therefore, overall approximated complexity per iteration is given as O Power : where, I R is denoted as the maximum number of iterations that are needed to achieve the optimal data rate. In the SDR method, the complexity can be determined by calculating the complex operations of the following terms. The terms Q and φ in Eq. (19) need (N + 1) 2 complex multiplications. (N + 1) 4.5 complex multiplications are required by the Gaussian randomization method to compute the best solution φ * . In addition, 2(K × M) complex multiplications are required for subcarriers power allocation computation. As a result, the overall approximated complexity is given as O SDR : The O SDR in (23) is very similar to the results provided in 8 and 6 where the complexities are O NKI SA + N 4.5 K 3.5 I T and O(N + 1) 4.5 , respectively. I SA denotes the number of iterations that the successive approximation requires and I T is the total time that is needed to solve the problem during the successive convex approximation algorithm. The run elapsed time in Table 1 is calculated using the tic toc function available in MATLAB. Complexity and run time are compared between the power method and the SDR for different number of elements N as presented in Table 1. For instance, if we consider the lowest number of elements (100) in Table 1 and compute the complexities taking into consideration the number of iterations, elements, subcarriers and channel taps. We notice that the complexity in the power method is in terms of thousands of operations while in the SDR is in terms of millions. Furthermore, the SDR method takes more run-time than the power method under different RIS sizes.  www.nature.com/scientificreports/

Simulation results
In this section, we evaluate the performance of the achievable data rate using the power method and compare it with the state-of-the-art SDR method. The simulation parameters provide in Table 2 are considered based on the 3GPP channel model 13 . We consider an OFDM system with K = 1000 subcarriers and a more realistic multi-path channel model with M = 23 channel taps at random delays with an exponential power decay profile. The deployment locations for the AP, RIS and user are shown in Fig. 1. We consider LoS channels between the AP-RIS-User indirect link as per Fig. 1, to guarantee effective transmissions and large channel gains. However, the non-line-of-sight (NLoS) propagation is assumed between the AP and the user. For Comparison with power method, we consider the following benchmark schemes: 1. The SDR method. 2. The strongest and the weakest SNR configurations which are generated from the codebook W θ 4N ∈ C N×4N . 3. The random phase case where we assume that each RIS reflecting coefficient has a random phase independently and uniformly distributed in [0 2π] and the maximum amplitude, based on which we obtain the water-filling transmit power allocation. 4. Un-configured surface where we replaced the RIS with a passive metal sheet causing zero phase-shifts.
First, we evaluate the convergence behaviour of Algorithm 1. The number of RIS reflecting elements is set to N = 2500 at SNR = 40 dB and 30 independent channel realizations. We notice that the achievable rate is generated progressively with higher values consistently. Figure 4 shows the achievable rate over several iterations. It is noticed that the minimum achievable value of the data rate is 214 [Mbps] while the highest one is 215.5 [Mbps] so, the difference is very small. Consequently, such a small difference in data rate values not only reflects the fast convergence but also validates the efficiency of the power method. We have initialized the power method from  www.nature.com/scientificreports/ the strongest SNR configuration that has been generated for the W θ 4N codebook which will, in turn, lead to higher data rate and small divergence values. In Fig. 5, we compare the achievable data rate of the proposed power method with the upper bound, the strongest, weakest SNR configuration selected from the W θ 4N codebook, random phase and lastly with the case when the surface is un-configured (a metal sheet case) for N = 4096 . The proposed power method outperforms both the strongest and weakest beamforming codebook, the random phase, and, the un-configured RIS case. The achievable data rate is dramatically boosted as the range of subcarriers increases. There is a gap between the rate achieved by the power method and that achieved by the beamforming codebook benchmark, and this gap gradually increases with the increase of number of subcarriers due to the increased channel frequency selectivity. However, the extended codebook W θ 4N = W θ , −W θ , W (θ ,flip) , −W θ ,flip ∈ C N×4N provides varieties of configurations that range from the weakest to the strongest SNR configurations which are, in return, lead to data rate enhancement. For example, the achievable data rate from the weakest to the strongest codebook configuration at N = 800 is around 120 [Mbps]. In comparison to un-configured RIS (metal sheet) configuration, the proposed power method approach improves the sum data rate by 2.5 order of magnitude.
In order to validate the performance of the proposed method, Fig. 6 shows the performance of the iterative power method and the benchmark schemes at different SNR values, with N = 400 . It is noticed that all the schemes with RIS (SDR method, power method and random phase) outperform the scheme without RIS (un-configured surface), owing to the RIS-enhanced average channel power between the AP and the user. Additionally, the proposed iterative power method and the SDR scheme both significantly outperform the random phase scheme in terms of achievable rate because of the tuned RIS coefficients that help the direct and the reflecting channel to be superimposed more constructively at the receiver. The SDR method shows slightly superior performance to the power method at low and high SNR regimes. Nevertheless, the performance gap between them is very small and can be sacrificed for the sake of practical implementations and lower complexity. Table 1 reveals that complexity increases when the number of elements increases in both SDR O SDR and power O Power methods. However, it is shown that complexity and run-time consumption in the SDR method is higher than the power method. Our proposed method is simple, practical and less complex than other algorithms 6,8 , as it uses fewer number of operations.
In Fig. 7, we compare the achievable rate of different schemes versus the number of RIS elements at SNR = 25 dB. Firstly, it is clear that the rate performance of the random phase shift scheme at the RIS is independent of the number of elements. This is to be expected since this method only has an aperture gain with no passive beamforming gain. Secondly, we can observe that both the SDR and the power method show superior performance as compared to the scheme with random phase shifts at the RIS and the un-configured surface. The achievable  www.nature.com/scientificreports/ rate of the power method and the SDR keep increasing as the number of elements increases. This makes sense since the passive beamforming performance is gradually enhanced.

Conclusion
In this paper, we showed that the RIS can be configured to provide significantly higher data rate, in comparison with un-configured surface, e.g., metal sheets. The codebook approach was implemented to generate varieties of phase configurations for the RIS surface in which we searched for the best configuration to be used in the optimization process. A problem formulation is described, and a solution is presented using the power method and the water-filling algorithm. To validate our proposed method, it is compared with the state-of-the art SDR scheme and the achievable data rates which are resulted from all methods are compared with the upper bound of the system. We noticed that the power method gives performance very close to the SDR method, however, our developed method shows less computational complexity and run-time.

Data availability
The data generated or analysed during this study are available from the corresponding author on reasonable request.